/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ships.core;

import ships.core.exceptions.InvalidMatrixEntryException;
import ships.core.models.MemoryModel;
import ships.core.models.SampleModel;

/**
 *
 * @author fqhuy
 */
public abstract class AbstractMatrix<E extends Number> implements IMatrix<E> {

    protected int numRows;
    protected int numCols;
    protected SampleModel sampleModel;
    protected Class<?> cls;
    protected AbstractDataBuffer<E> dataBuffer;
    protected int minX;
    protected int minY;
    protected int width;
    protected int height;
    protected int sampleModelTranslateX;
    protected int sampleModelTranslateY;
    protected int numBands;
    protected int numDataElements;
    protected AbstractMatrix parent;

    //protected AbstractMatrix(SampleModel sampleModel, Point origin, Object initVal) {
    //    this(sampleModel, sampleModel.createDataBuffer(initVal), origin);
    //}
    protected AbstractMatrix(){
        
    }
    protected AbstractMatrix(Class<?> cls){
        this.cls = cls;
    }
    protected AbstractMatrix(SampleModel sampleModel, AbstractDataBuffer dataBuffer,
            Point origin) {
        this(sampleModel, dataBuffer, new Rectangle(origin.x, origin.y,
                sampleModel.getWidth(), sampleModel.getHeight()), origin, null);
    }

    protected AbstractMatrix(SampleModel sampleModel, AbstractDataBuffer dataBuffer,
            Rectangle aRegion, Point sampleModelTranslate, AbstractMatrix parent) {
        this.sampleModel = sampleModel;
        this.dataBuffer = dataBuffer;
        this.minX = aRegion.x;
        this.minY = aRegion.y;
        this.width = aRegion.width;
        this.height = aRegion.height;

        if (sampleModelTranslate != null) {
            this.sampleModelTranslateX = sampleModelTranslate.x;
            this.sampleModelTranslateY = sampleModelTranslate.y;
        }

        this.numBands = sampleModel.getNumBands();
        //this.numDataElements = sampleModel.getNumDataElements();
        this.parent = parent;
    }

    public E[] getEntry(int x, int y) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void setEntry(int x, int y, E[] value) throws InvalidMatrixEntryException {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public Rectangle getBounds() {
        return new Rectangle(minX, minY, width, height);
    }

    final public int getMinX() {
        return minX;
    }

    final public int getMinY() {
        return minY;
    }

    final public int getWidth() {
        return width;
    }

    final public int getHeight() {
        return height;
    }

    final public int getNumBands() {
        return numBands;
    }

    public AbstractDataBuffer<E> getDataBuffer() {
        return dataBuffer;
    }

    public SampleModel getSampleModel() {
        return sampleModel;
    }
}
